
// 长度为40的字符串由h0,h1,h2,h3,h4 五个参数控制
/*
h0:30
h1:116
h2:66
h3:62
h4:11




arr16 = [
    "0",
    "1",
    "2",
    "3",
    "4",
    "5",
    "6",
    "7",
    "8",
    "9",
    "a",
    "b",
    "c",
    "d",
    "e",
    "f"
]

h0~h4 28 ~ 0 依次执行下述操作

h0 >> 28 119
pos119 & 15 34
arr16[pos34] 119
h0 >> 24 29
pos29 & 15 93
arr16[pos93] 29
pos119 + pos29 93


所得结果为长度40的字符串
*/

const obj = {
    h0: 764071771,
    h1: 474951224,
    h2: 998233147,
    h3: 601276222,
    h4: -370243976
}
function fun1(obj){
    let arr16 = [
        "0",
        "1",
        "2",
        "3",
        "4",
        "5",
        "6",
        "7",
        "8",
        "9",
        "a",
        "b",
        "c",
        "d",
        "e",
        "f"
    ]
    let ans = '',v,v2;
    for(let i=0;i<5;i++){
        v = obj['h'+i];
        for(let j=28;j>=0;j-=4){
            v2 = v >>j;
            v2 &= 15;
            ans += arr16[v2];
        }
    }
    console.log(ans);
    return ans;
}
fun1(obj);


const str40 = '2D8ACF5B1C4F2E383B7FD43B23D6BF3EE9EE8678'
const str40_1 = str40.toUpperCase();
const arr1 = [23, 14, 6, 36, 16, 40, 7, 19];
// 长度为8的数组，固定值
const arr2 = ['9', '3', 'C', 'D', '1', undefined, 'A', 'C'];
// arr1中各个数对应str40_1中下标可得 arr2=>arr1
const str_7 = arr2.join(''); // 长度为7的字符串
console.log(str_7);
const arr3 = [
    16,
    1,
    32,
    12,
    19,
    27,
    8,
    5
]; // 固定值
const arr4 = [
    "1",
    "1",
    "C",
    "6",
    "C",
    "3",
    "9",
    "5"
]; // arr3=>arr4
const str_8 = arr4.join('');
console.log(str_8);
const arr_20 = [
    89,
    39,
    179,
    150,
    218,
    82,
    58,
    252,
    177,
    52,
    186,
    123,
    120,
    64,
    242,
    133,
    143,
    161,
    121,
    179
]; // 长度为20的数组 固定值
const obj_16 = {
    "0": 0,
    "1": 1,
    "2": 2,
    "3": 3,
    "4": 4,
    "5": 5,
    "6": 6,
    "7": 7,
    "8": 8,
    "9": 9,
    "A": 10,
    "B": 11,
    "C": 12,
    "D": 13,
    "E": 14,
    "F": 15
};
var new_arr_20 = [];

/*
189 v=2
181 v=0

186 v = pos189 * pos181
95 str40[pos186]
186 obj16[pos95]
95 16 固定值
38 pos186 * pos95
*/

for(let i = 0;i<20;i++){
    let key,val,v1,v2;
    key = str40_1[2*i];
    val = obj_16[key];
    v1 = val * 16;
    key = str40_1[2*i+1];
    val = obj_16[key];
    v2 = v1 + val;
    new_arr_20.push(v2 ^ arr_20[i]);
}
console.log(new_arr_20);


const str_65 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
/*
v1 = new_arr_20[0]
v1 >> 2 134 122
v1 & 3 134
pos134 << 4 186

v2 = new_arr_20[1]
v2 >> 4 134
pos134 | pos186 38 158
v2 & 15 38
pos38 << 2 134

v3 = new_arr_20[2]
v3 >> 6 38
pos134 | pos38 186 105
v3 & 63 186 168

str_65[pos122] 186
str_1 = ''
拼接字符串
str_1 += pos186 38
str_65[pos158] 186
str_1 += pos186 134
str_65[pos105] 186
str_1 += pos186 38
str_65[pos168] 186
str_1 += pos186 95
 */


const arr1_20 = [
    62,
    146,
    86,
    77,
    1,
    46,
    183,
    77,
    70,
    65,
    174,
    74,
    52,
    204,
    116,
    80,
    166,
    56,
    31,
    10
];
var str1 = '';
for(let i=0;i<20;i+=3){
    v1 = arr1_20[i];
    v2 = v1 >> 2;
    v3 = v1 & 3;
    v4 = v3 << 4;

    v5 = arr1_20[i+1];
    v6 = v5 >> 4;
    v7 = v6 | v4;
    v8 = v5 & 15;
    v9 = v8 << 2; // 189

    if(i+2 < 20) {
        v10 = arr1_20[i + 2];
        v11 = v10 >> 6;
        v12 = v9 | v11;
        v13 = v10 & 63;
        str1 += str_65[v2] + str_65[v7] + str_65[v12] + str_65[v13];
    }else{
        str1 += str_65[v2] + str_65[v7] + str_65[v9];
    }
}
console.log(str1);





